package com.test.qnews.activity;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import com.test.qnews.R;
import com.test.qnews.adapter.GridViewAdapter;
import com.test.qnews.beans.GridBeans;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by dllo on 16/1/16.
 */
public class ConstellationActivity extends BaseActivity {
    private GridView gridView;
    private List<GridBeans> data;
    private GridViewAdapter gridViewAdapter;

    @Override
    protected int setLayout() {
        return R.layout.activity_constellation;
    }

    @Override
    protected void initView() {
        gridView = (GridView) findViewById(R.id.my_gridView);
        data = new ArrayList<>();
        data.add(new GridBeans("水瓶座", R.mipmap.shuiping, "1.20-1.28"));
        data.add(new GridBeans("双鱼座", R.mipmap.shuangyu, "2.19-3.20"));
        data.add(new GridBeans("白羊座", R.mipmap.baiyang, "3.21-4.19"));
        data.add(new GridBeans("金牛座", R.mipmap.jinniu, "4.20-5.20"));
        data.add(new GridBeans("双子座", R.mipmap.shuangzi, "5.21-6.21"));
        data.add(new GridBeans("巨蟹座", R.mipmap.juxie, "6.22-7.22"));
        data.add(new GridBeans("狮子座", R.mipmap.shizi, "7.23-8.22"));
        data.add(new GridBeans("处女座", R.mipmap.chunv, "8.23-9.22"));
        data.add(new GridBeans("天平座", R.mipmap.tianping, "9.23-10.23"));
        data.add(new GridBeans("天蝎座", R.mipmap.tianxie, "10.24-11.22"));
        data.add(new GridBeans("射手座", R.mipmap.sheshou, "11.23-12.21"));
        data.add(new GridBeans("摩羯座", R.mipmap.mojie, "12.22-1.19"));


//        GridView.setSelector(new ColorDrawable(Color.TRANSPARENT));// 设置item选中色
        gridViewAdapter = new GridViewAdapter(this, data);
        gridView.setAdapter(gridViewAdapter);

        gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(ConstellationActivity.this, NetActivity.class);
                if (position == 0) {
                    intent.putExtra("pos",position);
                    intent.putExtra(""+position ,"http://zzd.sm.cn/appservice/api/v1/sc/detail?query=%5B%7B%22name%22:%22fortune%22,%22fortune%22:%22%E6%B0%B4%E7%93%B6%E5%BA%A7%22%7D%5D");
                    startActivity(intent);
                }
                if (position == 1) {
                    intent.putExtra("pos",position);
                    intent.putExtra(""+position  ,"http://zzd.sm.cn/appservice/api/v1/sc/detail?query=%5B%7B%22name%22:%22fortune%22,%22fortune%22:%22%E5%8F%8C%E9%B1%BC%E5%BA%A7%22%7D%5D");
                    startActivity(intent);
                }
                if (position == 2) {
                    intent.putExtra("pos",position);
                    intent.putExtra(""+position ,"http://tieba.baidu.com/");
                    startActivity(intent);
                }
                if (position == 3) {
                    intent.putExtra("pos",position);
                    intent.putExtra(""+position  ,"http://baidu.com");
                    startActivity(intent);
                }
                if (position == 4) {
                    intent.putExtra("pos",position);
                    intent.putExtra(""+position ,"http://tieba.baidu.com/");
                    startActivity(intent);
                }
                if (position == 5) {
                    intent.putExtra("pos",position);
                    intent.putExtra(""+position  ,"http://baidu.com");
                    startActivity(intent);
                }
                if (position == 6) {
                    intent.putExtra("pos",position);
                    intent.putExtra(""+position ,"http://tieba.baidu.com/");
                    startActivity(intent);
                }
                if (position == 7) {
                    intent.putExtra("pos",position);
                    intent.putExtra(""+position  ,"http://baidu.com");
                    startActivity(intent);
                }
                if (position == 8) {
                    intent.putExtra("pos",position);
                    intent.putExtra(""+position ,"http://tieba.baidu.com/");
                    startActivity(intent);
                }
                if (position == 9) {
                    intent.putExtra("pos",position);
                    intent.putExtra(""+position  ,"http://baidu.com");
                    startActivity(intent);
                }
                if (position == 10) {
                    intent.putExtra("pos",position);
                    intent.putExtra(""+position ,"http://tieba.baidu.com/");
                    startActivity(intent);
                }
                if (position == 11) {
                    intent.putExtra("pos",position);
                    intent.putExtra(""+position  ,"http://baidu.com");
                    startActivity(intent);
                }
            }
        });

    }

}
